﻿using Portfolio.Data;
using Portfolio.DataModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace Portfolio.Web.Controllers
{
    public class PostsController : ApiController
    {
        public IHttpActionResult GET()
        {
            //Returns all posts
            return Ok();
        }
        public IHttpActionResult GET(int id)
        {
            //Return one post
            return Ok();
        }
        public IHttpActionResult POST(Post post)
        {
            //Create a post
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                post = db.Posts.Add(post);
            }

            //Return the Id of the post
            return Ok(post.Id);
        }
        public IHttpActionResult PATCH(Post post)
        {
            //Update a post
            return Ok();
        }
        public IHttpActionResult DELETE(int id)
        {
            //Delete the post
            return Ok();
        }
    }
}
